enum _AlibcBizPageType { guide, agent, rebate }

class AlibcBizExtParams {
  String? couponActivityId;
  String? vegasCode;
  _AlibcBizPageType pageType = _AlibcBizPageType.agent;
  String? flRate;
  String? dlRate;
  String? maxDlRate;
  String? isvUserId;

  static const _AlibcBizPageType PAGE_TYPE_GUIDE = _AlibcBizPageType.guide;
  static const _AlibcBizPageType PAGE_TYPE_AGENT = _AlibcBizPageType.agent;
  static const _AlibcBizPageType PAGE_TYPE_REBATE = _AlibcBizPageType.rebate;

  static AlibcBizExtParams newBuilder() {
    return new AlibcBizExtParams._();
  }

  AlibcBizExtParams._();

  AlibcBizExtParams setCouponActivityId(String couponActivityId) {
    this.couponActivityId = couponActivityId;
    return this;
  }

  AlibcBizExtParams setVegasCode(String vegasCode) {
    this.vegasCode = vegasCode;
    return this;
  }

  AlibcBizExtParams setPageType(_AlibcBizPageType pageType) {
    this.pageType = pageType;
    return this;
  }

  AlibcBizExtParams setFlRate(String flRate) {
    this.flRate = flRate;
    return this;
  }

  AlibcBizExtParams setDlRate(String dlRate) {
    this.dlRate = dlRate;
    return this;
  }

  AlibcBizExtParams setMaxDlRate(String maxDlRate) {
    this.maxDlRate = maxDlRate;
    return this;
  }

  AlibcBizExtParams setIsvUserId(String isvUserId) {
    this.isvUserId = isvUserId;
    return this;
  }

  Map toMap() {
    return {
      'couponActivityId': couponActivityId ?? '',
      'vegasCode': vegasCode ?? '',
      'pageType': ['guide', 'agent', 'rebate'][pageType.index],
      'flRate': flRate ?? '',
      'dlRate': dlRate ?? '',
      'maxDlRate': maxDlRate ?? '',
      'isvUserId': isvUserId ?? '',
    };
  }

  AlibcBizExtParams.from(Map map) {
    var pageTypes = {
      'guide': _AlibcBizPageType.guide,
      'agent': _AlibcBizPageType.agent,
      'rebate': _AlibcBizPageType.rebate
    };
    this.couponActivityId = map['couponActivityId'];
    this.vegasCode = map['vegasCode'];
    this.pageType = pageTypes[map['pageType']]!;
    this.flRate = map['flRate'];
    this.dlRate = map['dlRate'];
    this.maxDlRate = map['maxDlRate'];
    this.isvUserId = map['isvUserId'];
  }
}

class AlibcBizParams {
  String? id;
  String? shopId;
  String? sellerId;
  AlibcBizExtParams? extParams;

  static AlibcBizParams newBuilder() {
    return new AlibcBizParams._();
  }

  AlibcBizParams._();

  AlibcBizParams setId(String id) {
    this.id = id;
    return this;
  }

  AlibcBizParams setShopId(String shopId) {
    this.shopId = shopId;
    return this;
  }

  AlibcBizParams setSellerId(String sellerId) {
    this.sellerId = sellerId;
    return this;
  }

  AlibcBizParams setExtParams(AlibcBizExtParams extParams) {
    this.extParams = extParams;
    return this;
  }

  Map toMap() {
    return {
      'id': id,
      'shopId': shopId,
      'sellerId': sellerId,
      'extParams': extParams != null ? extParams?.toMap() : {}
    };
  }

  AlibcBizParams.from(Map map) {
    this.id = map['id'];
    this.shopId = map['shopId'];
    this.sellerId = map['sellerId'];
    this.extParams = AlibcBizExtParams.from(map['extParams']);
  }
}

class AlibcTaokeParams {
  String? pid;
  String? subPid;
  String? unionId;
  String? relationId;
  String? materialSourceUrl;
  Map<String, dynamic>? extParams;

  static AlibcTaokeParams newBuilder() {
    return new AlibcTaokeParams._();
  }

  AlibcTaokeParams._();

  AlibcTaokeParams setPid(String pid) {
    this.pid = pid;
    return this;
  }

  AlibcTaokeParams setSubPid(String subPid) {
    this.subPid = subPid;
    return this;
  }

  AlibcTaokeParams setUnionId(String unionId) {
    this.unionId = unionId;
    return this;
  }

  AlibcTaokeParams setRelationId(String relationId) {
    this.relationId = relationId;
    return this;
  }

  AlibcTaokeParams setMaterialSourceUrl(String materialSourceUrl) {
    this.materialSourceUrl = materialSourceUrl;
    return this;
  }

  AlibcTaokeParams setExtParams(Map<String, dynamic> extParams) {
    this.extParams = extParams;
    return this;
  }

  Map toMap() {
    return {
      'pid': pid,
      'subPid': subPid,
      'unionId': unionId,
      'relationId': relationId,
      'materialSourceUrl': materialSourceUrl,
      'extParams': extParams,
    };
  }

  AlibcTaokeParams.from(Map map) {
    this.pid = map['pid'];
    this.subPid = map['subPid'];
    this.unionId = map['unionId'];
    this.relationId = map['relationId'];
    this.materialSourceUrl = map['materialSourceUrl'];
    this.extParams = map['extParams'];
  }
}

enum _AlibcShowDegradeType { h5, download }
enum _AlibcShowOpenType { auto, native }
enum _AlibcShowClientType { taobao, tmall }

class AlibcShowParams {
  String? title;
  String? backUrl;
  String? degradeUrl;
  _AlibcShowDegradeType degradeType = _AlibcShowDegradeType.h5;
  _AlibcShowOpenType openType = _AlibcShowOpenType.auto;
  _AlibcShowClientType clientType = _AlibcShowClientType.taobao;

  static const _AlibcShowDegradeType DEGRADE_TYPE_H5 = _AlibcShowDegradeType.h5;
  static const _AlibcShowDegradeType DEGRADE_TYPE_DOWNLOAD =
      _AlibcShowDegradeType.download;

  static const _AlibcShowOpenType OPEN_TYPE_AUTO = _AlibcShowOpenType.auto;
  static const _AlibcShowOpenType OPEN_TYPE_NATIVE = _AlibcShowOpenType.native;

  static const _AlibcShowClientType CLIENT_TYPE_TAOBAO =
      _AlibcShowClientType.taobao;
  static const _AlibcShowClientType CLIENT_TYPE_TMALL =
      _AlibcShowClientType.tmall;

  static AlibcShowParams newBuilder() {
    return new AlibcShowParams._();
  }

  AlibcShowParams._();

  AlibcShowParams setBackUrl(String backUrl) {
    this.backUrl = backUrl;
    return this;
  }

  AlibcShowParams setDegradeUrl(String degradeUrl) {
    this.degradeUrl = degradeUrl;
    return this;
  }

  AlibcShowParams setDegradeType(_AlibcShowDegradeType degradeType) {
    this.degradeType = degradeType;
    return this;
  }

  AlibcShowParams setOpenType(_AlibcShowOpenType openType) {
    this.openType = openType;
    return this;
  }

  AlibcShowParams setTitle(String title) {
    this.title = title;
    return this;
  }

  AlibcShowParams setClientType(_AlibcShowClientType clientType) {
    this.clientType = clientType;
    return this;
  }

  Map toMap() {
    return {
      'backUrl': backUrl,
      'degradeUrl': degradeUrl,
      'degradeType': degradeType.index,
      'openType': openType.index,
      'title': title,
      'clientType': clientType.index,
    };
  }

  AlibcShowParams.from(Map map) {
    var degradeTypes = {
      "h5": _AlibcShowDegradeType.h5,
      "download": _AlibcShowDegradeType.download
    };
    var openTypes = {
      "auto": _AlibcShowOpenType.auto,
      "native": _AlibcShowOpenType.native
    };
    var clientTypes = {
      "taobao": _AlibcShowClientType.taobao,
      "tmall": _AlibcShowClientType.tmall
    };
    this.backUrl = map['backUrl'];
    this.degradeUrl = map['degradeUrl'];
    this.degradeType = degradeTypes[map['degradeType']]!;
    this.openType = openTypes[map['openType']]!;
    this.title = map['title'];
    this.clientType = clientTypes[map['clientType']]!;
  }
}
